import React,{useState} from 'react';
import Snackbar from '@material-ui/core/Snackbar';
import EventBus from '../../config/eventBus';
import MuiAlert from '@material-ui/lab/Alert';
import params from "./object";
import { makeStyles, Theme } from '@material-ui/core/styles';
function Alert(props) {
    return <MuiAlert elevation={6} variant="filled" {...props} />;
}
export default function NoticeDom() {
    const [open, setOpen,] = React.useState(false);
    const [param] = React.useState(params);

    const handleClick = () => {
        setOpen(true);
    };
    const handleClose = (event: React.SyntheticEvent | React.MouseEvent, reason?: string) => {
        if (reason === 'clickaway') {
            return;
        }
        setOpen(false);
    };

    EventBus.addListener("notify",(msg)=>{
        console.log(msg);
        console.log(param);
        setOpen(true);
    })
    return(
        <div>
            <Snackbar
                anchorOrigin={{
                    vertical: param.vertical,
                    horizontal:  param.horizontal,
                }}
                open={open}
                autoHideDuration={param.autoHideDuration}
                onClose={handleClose}
            >
                <Alert onClose={handleClose} severity="error">
                   {param.message}
                </Alert>
            </Snackbar>
        </div>

    );

}
